package com.sgb.kjwl.view.widget.lease.common.loadingview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

import com.sgb.kjwl.R;
import com.swgk.core.BaseAppApplication;
import com.swgk.core.xrecyclerview.SimpleViewSwitcher;


/**
 * Created by tdd on 2018/6/19.
 */

public class DefaultHorizontalLoadingView extends FooterLoadingView {
    private SimpleViewSwitcher mProgressBar;
    private TextView mLoadText;


    public DefaultHorizontalLoadingView(Context context) {
        this(context, null);
    }

    public DefaultHorizontalLoadingView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public DefaultHorizontalLoadingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        LayoutInflater.from(getContext()).inflate(R.layout.load_more, this, true);
        mLoadText = (TextView) findViewById(R.id.loadtext);
        mProgressBar = findViewById(R.id.progressBar);
        ProgressBar progressBar = new ProgressBar(getContext(), null, android.R.attr.progressBarStyle);
        progressBar.setIndeterminateDrawable(ContextCompat.getDrawable(getContext(), com.swgk.core.R.drawable.progressbar));
        mProgressBar.setView(progressBar);
    }

    @Override
    public void onPreLoading() {

    }

    @Override
    public void onLoading() {
        mProgressBar.setVisibility(View.VISIBLE);
        mLoadText.setVisibility(View.VISIBLE);
        mLoadText.setText(R.string.lease_home_loading);
    }

    @Override
    public void onLoaded() {
        mProgressBar.setVisibility(View.GONE);
        mLoadText.setVisibility(View.VISIBLE);
        mLoadText.setText(R.string.lease_home_complete);
    }

    @Override
    public void onComplete() {
        mProgressBar.setVisibility(View.GONE);
        mLoadText.setVisibility(View.VISIBLE);
        mLoadText.setText(R.string.lease_home_no_more_data);
    }

    @Override
    public void onReset() {
        mProgressBar.setVisibility(View.GONE);
        mLoadText.setVisibility(View.GONE);
    }
}
